#1, channels管理
from rest_framework.generics import ListAPIView, CreateAPIView
from rest_framework.viewsets import ModelViewSet

from goods.models import GoodsChannel, GoodsCategory, GoodsChannelGroup
from meiduo_admin.channel import channel_serializers

from meiduo_admin.my_pagination import MyPageNumberPagination


#1, 管理channel
class ChannelModelViewSet(ModelViewSet):
    pagination_class = MyPageNumberPagination
    serializer_class = channel_serializers.ChannelSerializers
    queryset = GoodsChannel.objects.all()

#2, 获取category
class ChannelCategoryView(ListAPIView):
    pagination_class = None
    serializer_class = channel_serializers.ChannelCategorySerializers
    queryset = GoodsCategory.objects.filter(parent_id=None).all()

#3,获取channel_types
class ChannelTypeView(ListAPIView):
    pagination_class = None
    serializer_class = channel_serializers.ChannelTypeSerializers
    queryset = GoodsChannelGroup.objects.all()
